package com.example.demo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 系统配置文件类
@Configuration // 该配置文件在项目启动时配置
public class ApplicationConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterception loginInterception; // 用户登录拦截器
    // 自定义拦截器添加到系统的配置文件中

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterception)
                .addPathPatterns("/**")       // 设置拦截规则
                .excludePathPatterns("/**/*.html")
                .excludePathPatterns("/product/recommended")
                .excludePathPatterns("/api/ai/chat")
                .excludePathPatterns("/auction/**")
                .excludePathPatterns("/profile/**")
                .excludePathPatterns("/category/**")
                .excludePathPatterns("/product/filter")
                .excludePathPatterns("/product/filter-by-category")
                .excludePathPatterns("/product/filter-by-price")
                .excludePathPatterns("/product/filter-by-condition")
                .excludePathPatterns("/comment/seller/**")
                .excludePathPatterns("/message/**")
                .excludePathPatterns("/user/get-user")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/**")
                .excludePathPatterns("/user/reg")
                .excludePathPatterns("/comment/get-all")
                .excludePathPatterns("/comment/get-by-rating")
                .excludePathPatterns("/alipay/**")
                .excludePathPatterns("/product/get-all")
                .excludePathPatterns("/product/choose")
                .excludePathPatterns("/product/detail")
                .excludePathPatterns("/kaptcha")
                .excludePathPatterns("/captcha")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/index.html")
                .excludePathPatterns("/img/**");



    }
}
